<?php

namespace frontend\models;

use Yii;
use yii\base\Model;

/**
 * ContactForm is the model behind the contact form.
 */
class NameForm extends Model
{
    public $name;
    public $email;
    public $test;
    public $age;
    public $name2;


    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            // // name, email, subject and body are required
            [['name', 'email'], 'required'],
            //比较 设置比较的值和比较的方法
            [['age'],'compare','compareValue'=>30,'operator'=>'>='],

            // // email has to be a valid email address
            // ['email', 'email'],
            // // verifyCode needs to be entered correctly
            // ['verifyCode', 'captcha'],
            ['name2','required','when'=>function(){

            }],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'name' => 'name 123',
            'email ' => 'email 456', 
            'test' => "tttttt"
        ];
    }
}
